package com.xin.di.uav.common.utils;

import java.util.HashMap;
import java.util.Map;

import javax.crypto.ShortBufferException;
import javax.naming.ConfigurationException;


import com.alibaba.fastjson.JSON;

import io.micrometer.common.util.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Auther: 01304522
 * @Date: 2022/1/12 16:19
 * 电话号码加解密工具类
 */
@Component
public class PhoneEncoderUtil {

    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(PhoneEncoderUtil.class);


    @Value("${encrypt.config-env:test}")
    private String encryptConfigEnv;


    /**
     * 加密数据标识
     */
    public static final String DATAENCRYPT_PREFIX = "DE";

    /**
     * 手机号码密钥索引
     */
    public static final int TEL_INDEX = 21;




    public String decryptString(String txt) {

        return null;
    }

    public String encryptString(String phone) {

        return null;
    }





    public static void main(String[] args) throws Exception {
        //String cfgPath = PhoneEncoderUtil.class.getClassLoader().getResource("dataEncrypt.cfg.ini").getFile();
        //System.out.println("cfgPath:"+cfgPath);
        String logpath = "args[0]";
        String host1 = "args[1]";
        String host2 = "args[2]";
        String conntimeout = "3000ms";
        String readtimeout = "1000ms";
        String strConfig = "{" + "[LOGGER];" + "logsw=error;" + "logPath=./logs;" + " [URGENT] ;" + "host = des-escape.intsit.sfdc.com.cn;" + "port = 1080;" + "conntimeout = 1000ms;" + "readtimeout = 1000ms;" + "[HOST 1];" + "hsmModel=VSM1310;" + "host=10.202.77.240;" + "port=1080;" + "connTimeout=" + conntimeout + ";" + "readTimeout=" + readtimeout + ";" + "msgHead = SUUtVUNTLUNPUkUgzt7Iy7v6udy/2M+1zbMAAAAAAAAAMUU2RDQwOEIwM0VFRkZDMAAAAAAAAAAAEgZvAAAAAFJDQ05HSzNTNFM1UwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=.J9/GGXjIng4hIi6WNm0IwaiDZX9ROo76YiKKQLBfCyQ=;" + "}";
        String phone = "17675768172";
//        String ss = encryptPhone(phone, userDataEncrypt);
        String ss = "DEEQAVTqi3hy1V5HvQcMJ48zkLtq4%3D";
        //String ID = "440981199402036521";
        //String ss = encryptId(ID,userDataEncrypt);

//        System.out.println("加密前:" + phone);
//        System.out.println("加密后:" + ss);
        //System.out.println(ByteTypeUtils.bytesToHexString(enString));
        /*for (byte b : desc.getBytes()) {
            System.out.printf("%02x ",b);
        }*/
    }


    public static String desensitization(String originalPhone) {
        originalPhone = originalPhone.substring(0, 3) + "****" + originalPhone.substring(7);
        return originalPhone;
    }
}

